// 路由的核心文件
import { createRouter, createWebHistory } from 'vue-router'
// 批量定义组件的URL，《不建议》
import HomeView from '../views/HomeView.vue'
//router：邮政局
const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  // 邮路：为每个组件定义一个唯一URL路径
  routes: [
    {
      path: '/',
      name: 'home',
      component: HomeView
    },
    {
      path: '/home',
      redirect: '/'
    },
    {
      path: '/about',
      name: 'about123',
      component: () => import('../views/AboutView.vue')
    },
    {
      path: '/grid',
      name: 'grid',
      component: () => import('../views/GridView.vue'),
      children: [
        {
          path: '/grid/table',
          name: 'table',
          component: () => import('../components/grid/GridTable.vue')
        },
        {
          path: '/grid/form',
          name: 'grid-form',
          component: () => import('../components/grid/GridTableForm.vue')
        }
      ]
    },
    {
      // :id :
      // 1、URL中的一部分
      // 2、匹配URL中的数据
      path: '/user/:id',
      name: 'user',
      component: () => import('../views/UserView.vue'),
      props: true
    }
  ]
})

export default router
